/* 
 * File:   Compiler.h
 * Author: Deste
 *
 * Created on 10 mars 2012, 23:32
 */

#ifndef COMPILER_H
#define	COMPILER_H

#include <iostream>
#include <stdio.h>
#include "Scanner.h"
#include "Writer.h"
#include "ExtendedSymbolTable.h"

using namespace std;

class Compiler
{
public:
        Compiler(const char filename[]);
        bool programP(void);
private:
        //Look-ahead token from the scanner
        Keywords currTok;
        Scanner* scanner;
        
        //Matches the terminal passed as parameter
        bool match(Keywords);
        //Methods representing the different productions
        bool varsP(ScopesP);
        bool idlistP(void);
        bool idlist1P(void);
        bool typeP(TypesP&);
        bool routinelistP(void);
        bool routineP(void);
        bool functionP(void);
        bool procedureP(void);
        bool argsoptP(string);
        bool argsP(ScopesP);
        bool args1P(ScopesP);
        bool blockP(ScopesP);
        bool statementoptP(ScopesP);
        bool statementlistP(ScopesP);
        bool stlist1P(ScopesP);
        bool statementP(ScopesP);
        bool stcontP(ScopesP,TypesP,string);
        bool callexpP(ScopesP,TypesP,string);
        bool expressionlistP(ScopesP);
        bool exlist1P(ScopesP);
        bool expressionP(ScopesP,TypesP&);
        bool c1P(ScopesP,TypesP&);
        bool c2P(ScopesP,TypesP&,TypesP&);
        bool tP(ScopesP,TypesP&);
        bool c3P(ScopesP,TypesP&);
        bool c4P(ScopesP,TypesP&,TypesP&);
        bool fP(ScopesP,TypesP&);
        bool c5P(ScopesP,TypesP&);
        bool c6P(ScopesP,TypesP&,TypesP&);
        bool gP(ScopesP,TypesP&);

};


/*int main(int argv, char** argc){
	printf("Hello, I'm a parser!");
	//Look at this! A comment!
        //First and only instantiation of Singleton elements
        ExtendedSymbolTable::getInstance();
        Writer::getInstance();
        //programP();
        getchar();
	return 0;
 * 
 * 
 * 
 * 
}
 
 
 
 */


#endif	/* COMPILER_H */

